package com.example.hyw.szysteam.view;

import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.hyw.szysteam.R;
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton;

/**
 * Created by HYW on 2018/6/7.
 */

public class CreateClassSuccessDialog extends DialogFragment {
    String invitecode;
    TextView tInvitecode;
    QMUIRoundButton buttonClip;
    View view;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view=inflater.inflate(R.layout.fragment_createclasssuccess,container,false);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
    }

    public void initView(){
        tInvitecode=view.findViewById(R.id.invitecode);
        buttonClip=view.findViewById(R.id.button_clip);
        tInvitecode.setText(invitecode);
        buttonClip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ClipboardManager cm=(ClipboardManager)getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                cm.setText(tInvitecode.getText());
                Toast.makeText(getContext(),"复制成功，快发给同学们吧！",Toast.LENGTH_LONG).show();
            }
        });
    }

    public void setInvitecode(String invitecode) {
        this.invitecode = invitecode;
    }
}
